package com.cictec.middleware.gps.engine.position.handler;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import com.cictec.middleware.commons.utils.log.MultiLog;
import com.cictec.middleware.gps.engine.BusInstance;
import com.cictec.middleware.gps.engine.exception.BusPositionHandlerException;
import com.cictec.middleware.gps.engine.position.BusPositionHandler;
import com.cictec.middleware.gps.engine.utils.MultiLogUtil;

/**
 * 日志
 * 
 * @author zhou qi
 *
 */
@Component
public class BusPositionLogHandler implements BusPositionHandler {

	private static Logger logger = LoggerFactory.getLogger(BusPositionLogHandler.class);
	
	@Override
	public void onHandler(BusInstance busInstance) throws BusPositionHandlerException {
		// TODO Auto-generated method stub
		showPostionLog(busInstance);
		
	}
	
	public void showPostionLog(BusInstance busInstance) {

		MultiLog log = MultiLogUtil.getPositionJudgeLog(busInstance);
		
		String positionLogStr = getPositionLog(busInstance);

		log.debug(positionLogStr);
		logger.debug(positionLogStr);

	}

	
	private static String getPositionLog(BusInstance busInstance){
		String logStr = ""
//				+ "\n 设备号：" + busInstance.getDevCode()
//				+ "\n 设备uuid：" + busInstance.getDevUuid()
//				+ "\n 设备数据上传时间：" + busInstance.getUploadTime()
				+ "\n 设备数据上传采集时间：" + busInstance.getGatherTime()
//				+ "\n 设备数据上传存储时间：" + busStatus.get(Constants.HED_UPLOAD_TIME)
//				+ "\n longitude: " + busInstance.getLongitude()
//				+ "\n latitude: " + busInstance.getLatitude()
//				+ "\n 北纬、南纬: " + busInstance.getLatitudeIndicator()
//				+ "\n 东经、西经: " + busInstance.getLongitudeIndicator()
//				+ "\n 角度: " + busInstance.getCounrse()
//				
//				+ "\n 车辆 uuid: " + busInstance.getBusUuid()
//				+ "\n 车辆 号码: " + busInstance.getBusNumber()
//				+ "\n 车辆 自编号: " + busInstance.getBusSelfCode()

//				+ "\n 司机uuid : " + busInstance.getDriverUuid()
//				+ "\n 司机名称 : " + busInstance.getDriverName()
//				+ "\n 司机卡号 : " + busInstance.getDriverIccard()
//				+ "\n 电话号码 : " + busInstance.getCallPhone()
//				
//				+ "\n 线路设备id : " + busInstance.getDevLineId()
//				+ "\n 线路uuid : " + busInstance.getLineUuid()
//				+ "\n 线路名称 : " + busInstance.getLineName()
				
				// 进站：站点为当前站；出站：站点为下一站
				+ "\n 待发区标识(0：不在待发区、1:上行待发、2:下行待发区): " + busInstance.getStatusStandBy()
				+ "\n 进出站状态(1： 进站、2：出站) : " + busInstance.getStationEnterOut()
				+ "\n 站点序号 : " + busInstance.getStationSeq()
				+ "\n 站点名称: " + busInstance.getStationName()

				+ "\n 车辆运营状态(0:【非运营】不在运营时间内、1：【运营】在运营时间内) : " + busInstance.getStatusInOperateTime()
//				+ "\n 调度状态(0-可调度； 大于0 为不可调度； 1: 维修；2:年检；3:其它): " + busStatus.get(Constants.MSG_INFO_DISPATCH_STATUS)			// 0-可调度； 大于0 为不可调度； 1 -- 维修；2 -- 年检；3--其它
				+ "\n 是否偏线(0:未偏线、1：偏线): " + busInstance.getStatusDeviate()
				+ "\n 方向 (1:上行、2：下行): " + busInstance.getLineType()
				+ "\n 相对距离【线路】: " + busInstance.getPositionRate()
//				+ "\n 相对距离【站点】: " + busInstance.getPositionStationRate()
				+ "\n 车速: " + busInstance.getSpeed()
				
				
				+ "\n 当前班次: " + busInstance.getCurrentShift()
				+ "\n 当前趟次: " + busInstance.getCurrentTrip()		// 
				+ "\n 当前趟次计划发车时间: " + busInstance.getCurrentTripPlanTime()
				+ "\n 当前趟次实际发车时间: " + busInstance.getCurrentTripStartTime()
//				+ "\n 下一班次: " + busInstance.getNextShift()
//				+ "\n 下一趟次: " + busInstance.getNextTrip()
				+ "\n 下一个趟次发车时间: " + busInstance.getNextTripPlanTime()
//
				+ "\n 所有的报警: " + busInstance.getAllAlarms()


//				+ "\n 是否回场(0：未回场、1:已回场): " + busInstance.getInPark()
//				+ "\n 是否应该回场(0:不必要回场、1:需要回场): " + busInstance.getShouldPark()
				+ "";
		return logStr;
	}
}
